package com.framework.loippi.service.impl;

import com.framework.loippi.dao.TUserDao;
import com.framework.loippi.entity.TUser;
import com.framework.loippi.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * SERVICE - TUSER(用户表(微信信息))
 * 
 * @author wmj
 * @version 2.0
 */
@Service
public class TUserServiceImpl extends GenericServiceImpl<TUser, Long> implements TUserService {
	
	@Autowired
	private TUserDao tUserDao;
	
	
	@Autowired
	public void setGenericDao() {
		super.setGenericDao(tUserDao);
	}

	public List<TUser> findListByPage(Object parameter) {
		return tUserDao.findListByPage(parameter);
	}

	public Long deletes(Object parameter){
		return tUserDao.deletes( parameter);
	}

	@Override
	public TUser findByOpenId(String openId) {
		return tUserDao.findByOpenId(openId);
	}

	@Override
	public TUser findByPhone(String mobile) {
		return tUserDao.findByPhone(mobile);
	}

	@Override
	@Transactional
	public Long openUser(Long[] ids) {
		TUser user = null;
		for (Long id : ids) {
			user = new TUser();
			user.setId(id);
			user.setIsEnable(1);
			tUserDao.update(user);
		}
		return 1L;
	}

	@Override
	@Transactional
	public Long closeUser(Long[] ids) {
		TUser user = null;
		for (Long id : ids) {
			user = new TUser();
			user.setId(id);
			user.setIsEnable(0);
			tUserDao.update(user);
		}
		return 1L;
	}
}
